
/**
 * AppleIIGo
 * Super Serial Card class
 * (C) 2008 by Marc S. Ressl (mressl@umich.edu)
 * Released under the GPL
 */

#include "SuperSerialCard.h"

SuperSerialCard::SuperSerialCard(Motherboard * motherboard,
								 char * slotDeviceName) :
SlotDevice(motherboard, slotDeviceName) {
}

void SuperSerialCard::onMemoryRequested() {
	romMemoryOffset =
		motherboard->getMemory()->requestMemory(SUPERSERIALCARD_ROM_BYTENUM);
}

void SuperSerialCard::onMemoryAllocated() {
	romMemory = motherboard->getMemory()->getMemory(romMemoryOffset);
	char * romImage = "Apple II Super Serial Card ROM.bin";
	motherboard->getResources()->readResource(romMemory, 
											  SUPERSERIALCARD_ROM_BYTENUM,
											  romImage);
}

void SuperSerialCard::writeIo(UINT16 address, UINT8 value) {
}

UINT8 SuperSerialCard::readIo(UINT16 address) {
	return timingGenerator->readFloatingBus();
}

UINT8 SuperSerialCard::readMemory(UINT16 address) {
	if ((address & 0xf00) == 0xf00)
		return timingGenerator->readFloatingBus();
	else if (address & 0x800)
		return romMemory[address & 0x7ff];
	else
		return romMemory[0x700 | (address & 0xff)];
}
